const baseURL = 'http://211.103.34.48:8980/js/api'

// 封装统一请求
const request = ({
  url,
  data = {}
}) => {
  return new Promise((resolve, reject) => {
    uni.showLoading({
      title: '请求中...'
    })
    uni.request({
      url: `${baseURL}${url}`,
      data,
      header: {
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      method: 'POST',
      success(res) {
        return resolve(res)
      },
      fail(error) {
        return reject(error)
      },
      complete() {
        uni.hideLoading()
      }
    })
  })
}

export default request
